package com.wbs.controller;

import com.wbs.aop.LogAn;
import com.wbs.resutil.PageBean;
import com.wbs.resutil.PageResult;
import com.wbs.resutil.Result;
import com.wbs.service.TypeTemplateService;
import com.wbs.vo.TypeTemplateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 芝梦
 * @Description: 模板管理 控制层
 * @DateTime: 2024/1/25 16:35
 */
@RequestMapping("typeTemplate")
@RestController
public class TypeTemplateController {
    @Autowired
    private TypeTemplateService typeTemplateService;

    @LogAn
    @PostMapping("findTypeTemplatePage")
    public Result findTypeTemplatePage(@RequestBody PageBean<TypeTemplateVo> pageBean){
        PageResult<TypeTemplateVo> pageResult = typeTemplateService.findTypeTemplatePage(pageBean);
        return Result.SUCCESS().setData(pageResult);
    }

    @LogAn
    @GetMapping("selectByKey")
    public Result selectByKey(@RequestParam Long id){
        TypeTemplateVo typeTemplateVo = typeTemplateService.selectByKey(id);
        return Result.SUCCESS().setData(typeTemplateVo);
    }

    @PostMapping("add")
    public Result add(@RequestBody TypeTemplateVo typeTemplateVo){
        typeTemplateService.add(typeTemplateVo);
        return Result.SUCCESS();
    }
    @PutMapping("update")
    public Result update(@RequestBody TypeTemplateVo typeTemplateVo){
        typeTemplateService.update(typeTemplateVo);
        return Result.SUCCESS();
    }

    @DeleteMapping("delete")
    public Result delete(@RequestParam Long id){
        typeTemplateService.delete(id);
        return Result.SUCCESS();
    }

}
